package org.ru.mse10.cvis.entity.cv;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.MapKey;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.ru.mse10.cvis.constants.UserNamedQueries;
import org.ru.mse10.cvis.constants.UserRole;
import org.ru.mse10.cvis.entity.misc.Identity;

/**
 * The Class User.
 */
@Entity
@Table(name = "user")
@NamedQueries(value = {
		@NamedQuery(name = UserNamedQueries.QUERY_CHECK_LOGIN_KEY, query = UserNamedQueries.QUERY_CHECK_LOGIN),
		@NamedQuery(name = UserNamedQueries.QUERY_CHECK_EMAIL_KEY, query = UserNamedQueries.QUERY_CHECK_EMAIL),
		@NamedQuery(name = UserNamedQueries.QUERY_HASH_BY_EMAIL_KEY, query = UserNamedQueries.QUERY_HASH_BY_EMAIL),
		@NamedQuery(name = UserNamedQueries.QUERY_USER_BY_EMAIL_KEY, query = UserNamedQueries.QUERY_USER_BY_EMAIL) })
public class User extends Identity {

	/** The role. */
	private UserRole role;

	/** The name. */
	private String name;

	/** The middle name. */
	private String middleName;

	/** The last name. */
	private String lastName;

	/** The email. */
	private String email;

	/** The password. */
	private String password;

	/** The cvs. */
	private Map<String, CvData> cvs = new HashMap<String, CvData>();

	/**
	 * Gets the role.
	 * 
	 * @return the role
	 */
	public UserRole getRole() {
		return role;
	}

	/**
	 * Sets the role.
	 * 
	 * @param role
	 *            the new role
	 */
	public void setRole(UserRole role) {
		this.role = role;
	}

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the middle name.
	 * 
	 * @return the middle name
	 */
	public String getMiddleName() {
		return middleName;
	}

	/**
	 * Sets the middle name.
	 * 
	 * @param middleName
	 *            the new middle name
	 */
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	/**
	 * Gets the last name.
	 * 
	 * @return the last name
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * Sets the last name.
	 * 
	 * @param lastName
	 *            the new last name
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/**
	 * Gets the email.
	 * 
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * Sets the email.
	 * 
	 * @param email
	 *            the new email
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * Gets the password.
	 * 
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Sets the password.
	 * 
	 * @param password
	 *            the new password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Gets the cvs.
	 * 
	 * @return the cvs
	 */
	@OneToMany(mappedBy = "user")
	@MapKey(name = "language")
	public Map<String, CvData> getCvs() {
		return cvs;
	}

	/**
	 * Sets the cvs.
	 * 
	 * @param cvs
	 *            the cvs
	 */
	public void setCvs(Map<String, CvData> cvs) {
		this.cvs = cvs;
	}

}
